<?php
/**
 * Created By PhpStorm
 * Author: patrick wu
 * Date: 2020/10/9
 * Time: 14:01
 */
namespace App\Service\Api;

use App\Http\Model\MongoDB\ShopTemplate;
use App\Http\Model\Mysql\HotKeywordModel;

class SundryService extends BaseService
{
    /**
     * 热门搜索词列表
     * @return array
     */
    public function sundryHot()
    {
        $list   =   HotKeywordModel::query()->select(['id', 'keyword', 'sorting'])->orderBy('sorting', 'desc')->get();
        return [true, $list->isEmpty() ? [] : $list->toArray()];
    }

    /**
     * 模板内容详情
     * @param string $template_id  模板ID
     * @return array
     */
    public function sundryTemplate(string $template_id)
    {
        //, 'templateType' => ShopTemplate::SPECIAL_TEMPLATE
        $info_result    =   ShopTemplate::where(['_id' => $template_id])->select(['_id', 'release', 'templateName', 'templateType', 'page', 'pageTitle', 'companyId', 'appId', 'sortOrder'])->first();
        if (empty($info_result)) {
            return [false, '模板不存在'];
        } else {
            return [true, $info_result];
        }
    }
}
